package com.tencent.qcloud.qiaoqiao.ui.tools;

import android.support.v4.content.ContextCompat;
import android.text.TextUtils;

import com.tencent.qcloud.qiaoqiao.mainui.list.TCVideoInfo;
import com.tencent.qcloud.qiaoqiao.ui.bean.CollectBean;
import com.tencent.qcloud.qiaoqiao.ui.tools.utilCode.ActivityUtils;

import java.util.ArrayList;
import java.util.List;

public class MyAppUtils {

    public static List<TCVideoInfo> getPlayVideoData(List<CollectBean.ListBean> videoBeanList){
        List<TCVideoInfo> playVideoList = new ArrayList<>();//.clear();
        for (CollectBean.ListBean bean: videoBeanList){
            TCVideoInfo tcLiveInfo = new TCVideoInfo();
            tcLiveInfo.title = getTitle(bean.getTitle());
            tcLiveInfo.playurl = bean.getPlay_url();
            tcLiveInfo.fileid = bean.getFile_id();
            tcLiveInfo.avatar = bean.getAvatar();
            tcLiveInfo.hlsPlayUrl = bean.getPlay_url();
            tcLiveInfo.frontcover = bean.getFrontcover();
            tcLiveInfo.review_status = bean.getReview_status();
            tcLiveInfo.nickname = bean.getNickname();
            tcLiveInfo.createTime = bean.getCreate_time();
            tcLiveInfo.userid = bean.getUserid();
            tcLiveInfo.interest_state = bean.getInterest_state();
            tcLiveInfo.commend_state = bean.getCommend_state();
            tcLiveInfo.collection_state = bean.getCollection_state();
            playVideoList.add(tcLiveInfo);
        }
        return  playVideoList;
    }

    public static  String getTitle(String name){
        String mName;
        if (TextUtils.isEmpty(name)|| "null".equals(name)){
            mName="--";
        }else{
            mName = name;
        }
        return mName;
    }

    public static  String getName(String name){
        String mName;
        if (TextUtils.isEmpty(name)|| "null".equals(name)){
            mName= ActivityUtils.getTopActivity().getString(com.chad.library.R.string.app_name);
        }else{
            mName = name;
        }
        return mName;
    }
}
